package main

import (
	"02-func/src/define"
	_ "02-func/src/define"
	"fmt"
	"math"
)

func main() {
	//define
	s1:=define.Test(func() int {
		return 100
	})

	s2:=define.Format(func(s string, x, y int) string {
		return fmt.Sprintf(s,x,y)
	},"%d,%d",10,20)
	println("define:-------->")
	println(s1,s2)

	//param
	var a,b = 1,2
	define.Swap(&a,&b)
	println("param:---------->")
	println(a,b)
	println(define.ParamTest("sum:%d",1,2,3))

	//return
	var c,d = 1,2
	e:=define.Add(c,d)
	sum,avg:=define.Calc(c,d)
	println("return:---------->")
	println(c,d,e,sum,avg)

	//defer
	var a1,b1 = 1,2
	c1:=define.DeferAdd(a1,b1)
	println("defer:------------->")
	println(c1)

	//anonymity
	getSqrt := func(a float64) float64 {
		return math.Sqrt(a)
	}
	println("getSqrt:----------->")
	println(getSqrt(4))

}
